package pers.mine.po;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;


import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * 前台弹幕表
 * @author Mine
 * @since 2017年5月29日_上午9:25:50
 */
public class FrontDanmaku extends BasePO{
	@JsonProperty(value = "_id") 
	private String id;
	
    private String frontUserId;

    private String frontVedioId;

    private Double time;

    private String text;

    private String color;

    private String type;
    @JsonProperty(value = "__v") 
    private Integer v;

    private Date createTime;
   
    private List<String> player; //弹幕视频id
    
    public String getFrontUserId() {
        return frontUserId;
    }

    public void setFrontUserId(String frontUserId) {
        this.frontUserId = frontUserId;
    }

    public String getFrontVedioId() {
        return frontVedioId;
    }

    public void setFrontVedioId(String frontVedioId) {
        this.frontVedioId = frontVedioId;
    }

    public Double getTime() {
        return time;
    }

    public void setTime(Double time) {
        this.time = time;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Integer getV() {
        return v;
    }

    public void setV(Integer v) {
        this.v = v;
    }
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Override
	public String toString() {
		return "FrontDanmaku [frontUserId=" + frontUserId + ", frontVedioId="
				+ frontVedioId + ", time=" + time + ", text=" + text
				+ ", color=" + color + ", type=" + type + ", v=" + v
				+ ", createTime=" + createTime + ", id=" + id + ", state="
				+ state + "]";
	}

	public List<String> getPlayer() {
		return player;
	}

	public void setPlayer(List<String> player) {
		this.player = player;
	}
	
	public static FrontDanmaku parseDanmakuFromMap(Map<String,Object> map) throws Exception{
		FrontDanmaku one=null;
		if(map!=null){
			one=new FrontDanmaku();
			Object temp=map.get("color");
			one.setColor(temp==null?null:temp.toString());
			temp=map.get("type");
			one.setType(temp==null?null:temp.toString());
			temp=map.get("text");
			one.setText(temp==null?null:temp.toString());
			List<String> player=null;
			temp=map.get("player");
			String pOne= (temp==null?null:temp.toString());
			if(pOne!=null){
				player=new ArrayList<>();
				player.add(pOne);
			}
			one.setFrontVedioId(pOne);//设置视频id
			one.setPlayer(player);
			temp=map.get("time");
			String timeStr=(temp==null?null:temp.toString());
			one.setTime(Double.parseDouble(timeStr));
		}
		return one;
	}
}